<?php
namespace app\frontend\controller;
use think\Db;
use think\captcha\Captcha;
use think\Controller;
class Search extends Controller
{
	/*public function index()
    {
        if(!session('user_id'))
        {
            $user_name='登录';
            $login='/frontend/login/index';
            $user_register='注册';
            $user_logout='';
        }
        else
        {
            if(!session('user_name'))
          {
            $user_name=session('user_phone');
          }
          else
          {
            $user_name=session('user_name');
          }
            $login='/frontend/person/index';
            $user_register='欢迎你';
            $user_logout='退出';
        }

        $this->assign('login',$login);
        $this->assign('user_name',$user_name);
        $this->assign('user_register',$user_register);
        $this->assign('user_logout',$user_logout);
    	return view('./index/search');
    }*/
    public function search()
    {
        if(!session('user_id'))
        {
            $user_name='登录';
            $login='/frontend/login/index';
            $user_register='注册';
            $user_logout='';
        }
        else
        {
            if(!session('user_name'))
          {
            $user_name=session('user_phone');
          }
          else
          {
            $user_name=session('user_name');
          }
            $login='/frontend/person/index';
            $user_register='欢迎你';
            $user_logout='退出';
        }

        $this->assign('login',$login);
        $this->assign('user_name',$user_name);
        $this->assign('user_register',$user_register);
        $this->assign('user_logout',$user_logout);
    	$key=input('get.key');
    	$ret=db('product')->where('product_name','like','%'.$key.'%')->select();
    
    	$this->assign('ret',$ret);


    	return view('./index/search');
    } 
}